package org.giovanolli.mumi.entities;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;

/**
 * The Class Speciality.
 */
@Entity
@Table(name = "speciality")
public class Speciality extends IdentificableEntity {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -4352732676767372688L;

	/** The name. */
	@Column(name = "name", unique = true)
	private String name;

	/** The specialists. */
	// @OneToMany
	// @JoinColumn(name = "speciality_id")
	// private List<Specialist> specialists;

	@ManyToMany
	@JoinTable(name = "specialist_specialities", joinColumns = @JoinColumn(name = "speciality_id"), inverseJoinColumns = @JoinColumn(name = "specialist_id"))
	@ForeignKey(name = "fk_specialist_speciality_speciality", inverseName = "fk_specialist_speciality_specialist")
	private List<Specialist> specialists = new ArrayList<Specialist>();

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Gets the specialists.
	 * 
	 * @return the specialists
	 */
	public List<Specialist> getSpecialists() {
		return specialists;
	}

	/**
	 * Sets the name.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Sets the specialists.
	 * 
	 * @param specialists
	 *            the new specialists
	 */
	public void setSpecialists(List<Specialist> specialists) {
		this.specialists = specialists;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.giovanolli.mumi.entities.IdentificableEntity#toString()
	 */
	@Override
	public String toString() {
		return "Speciality [name=" + name + ", toString()=" + super.toString() + "]";
	}

}
